package jianzhi_offer;

public class _43_翻转单词顺序列 {
    public static void main(String[] args) {
        _43_翻转单词顺序列 test = new _43_翻转单词顺序列();
        System.out.println(test.ReverseSentence("student. a am I"));
    }

    public String ReverseSentence(String str) {
        if(str.trim().equals("")){
            return str;
        }
        String[] strs = str.split(" ");
        StringBuilder sb = new StringBuilder();
        for(int i=strs.length-1;i>=0;--i){
            sb.append(strs[i]).append(" ");
        }
        sb.deleteCharAt(sb.length()-1);
        return sb.toString();
    }
}
